// JavaScript Document
//xml异步提交 result:data[0]预定值 funName:传输正常时执行的函数
function do_ajax(url,result,funName){
	var http_request=new XMLHttpRequest();
	
	http_request.open("GET",url);
	http_request.send(null);
	
	http_request.onreadystatechange=function(){
		switch(http_request.readyState){
			case 0: break; case 1: break; case 2: break;
			case 4:
			var data=http_request.responseText;
			data=eval(data);
			if(data[0]==result){
				eval(funName);;
			}else alert("Cood is wrong!");
		}
	}
}

//屏幕滚动函数 nums:滚动屏数 speed:滚动速度 
var tar_pos=0;
var s_height=document.documentElement.clientHeight;
function screenScroll(nums,speed){
	var now_pos=document.body.scrollTop;
	if(tar_pos==0) tar_pos=now_pos+s_height*nums;
	if(now_pos>tar_pos&&now_pos-tar_pos>100){
		document.body.scrollTop-=speed;
		setTimeout("screenScroll("+nums+","+speed+")",10);
	}else if(now_pos<tar_pos&&tar_pos-now_pos>100){
		document.body.scrollTop+=speed;
		setTimeout("screenScroll("+nums+","+speed+")",10);
	}else{
		document.body.scrollTop=tar_pos;
		tar_pos=0;
	}
}

//判断是否为微信浏览器
function isWeiXin(){                                      
    var ua = window.navigator.userAgent.toLowerCase();
    if(ua.match(/MicroMessenger/i) == 'micromessenger'){
        return true;
    }else{
        return false;
    }
}

//区分智能机浏览器
function getBrowser(){
	var browser = {
versions: function() {
var u = navigator.userAgent, app = navigator.appVersion;
return {//移动终端浏览器版本信息 
trident: u.indexOf('Trident') > -1, //IE内核
presto: u.indexOf('Presto') > -1, //opera内核
webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/), //是否为移动终端
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否为iPhone或者QQHD浏览器
iPad: u.indexOf('iPad') > -1, //是否iPad
webApp: u.indexOf('Safari') == -1 //是否web应该程序，没有头部与底部
};
}(),
language: (navigator.browserLanguage || navigator.language).toLowerCase()
}
 
if (browser.versions.ios || browser.versions.iPhone || browser.versions.iPad) {
	//apple 浏览器
	return "apple";
}
else if (browser.versions.android) {
	//android 浏览器
	return "android";
}
else{
	//其他浏览器
	return "other";
}
}
